import Vue from 'vue'
import Router from 'vue-router'
import Login from 'pages/login/login'
import Dashboard from 'pages/index/index'
import History from 'pages/history/history'
import Logs from 'pages/logs/logs'
import Task from 'pages/task/task'

Vue.use(Router)

export const createRouter = () => {
  return new Router({
    mode: 'history',
    routes: [
      {
        path: '/dashboard',
        component: Dashboard,
        children: [
          {
            path: '/',
            redirect: 'task'
          },
          {
            path: 'task',
            name: 'task',
            component: Task
          },
          {
            path: 'history',
            name: 'history',
            component: History
          },
          {
            path: 'logs',
            name: 'logs',
            component: Logs
          }
        ]
      },
      {
        path: '/login',
        component: Login,
        name: 'login'
      },
      {
        path: '*',
        redirect: '/login'
      }
    ]
  })
}
